package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 小薛超人
 * @version 1.0
 * @description: TODO
 * @date 2025/7/21 14:19
 */
@RestController
@RequestMapping("/prod/type")
@Api(tags = "商品分类")
public class TypeController {

    @Autowired
    TbTypeService tbTypeService;

    @PostMapping("/getTypeTree")
    @ApiOperation(value = "商品类型树")
    public R getTypeTree(@RequestBody PageInfoVo pageInfoVo){
        return tbTypeService.getTypeTree(pageInfoVo);
    }

    @PostMapping("/uploadImages")
    @ApiOperation(value = "上传图片")
    public R uploadImages(@RequestBody MultipartFile file){
        return tbTypeService.uploadImages(file);
    }

    @PostMapping("/addType")
    @ApiOperation(value = "添加类型")
    public R addType(@RequestBody @Validated TbType tbType){
        return tbTypeService.addType(tbType);
    }
}
